 package patrol.mobile.com.mobilepatrol.adapter;

 import android.content.Context;
import android.view.View;

import com.dl7.recycler.adapter.BaseQuickAdapter;
import com.dl7.recycler.adapter.BaseViewHolder;

import java.util.List;

import patrol.mobile.com.mobilepatrol.R;
import patrol.mobile.com.mobilepatrol.activity.road_survey.TrafficInvestActivity;
import patrol.mobile.com.mobilepatrol.bean.TrafficInvestBaseInfo;
 import patrol.mobile.com.mobilepatrol.manager.UserManager;

 /**
 * Created by long on 2016/8/24.
 * 桥梁巡查列表
 */
public class TrafficInvestListAdapter extends BaseQuickAdapter<TrafficInvestBaseInfo> {
    private TrafficInvestActivity context;
    public TrafficInvestListAdapter(Context context, List<TrafficInvestBaseInfo> data) {
        super(context, data);
        this.context = (TrafficInvestActivity) context;
    }

    @Override
    protected int attachLayoutRes() {
        return R.layout.item_road;
    }

    @Override
    protected void convert(final BaseViewHolder holder, final TrafficInvestBaseInfo item) {
        holder.setText(R.id.index, item.index+"");
        holder.setText(R.id.tv1, item.surveyTask);

        holder.setText(R.id.tv4, item.surveyLine+"(K"+item.startPotKm+"+"+item.startPotMeter+" - K"+item.endPotKm2+"+"+item.endPotMeter2+")");
        holder.setText(R.id.tv6, item.roadLevel);
        holder.setText(R.id.tv7, item.getSurveyDate());
        holder.setText(R.id.tv5, item.surveyWay);
        holder.setText(R.id.tv_name, UserManager.getryName());
        holder.getView(R.id.tv_detail).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                context.goDetail(item);
            }
        });
        //0没有上传
        if (item.status==0){
            holder.setInVisible(R.id.iv_up,false);
            holder.setInVisible(R.id.iv_noup,true);
            holder.getView(R.id.iv_noup).setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    context.uploadInvestInfo(item);
                }
            });
        }else{
            holder.setInVisible(R.id.iv_up,true);
            holder.setInVisible(R.id.iv_noup,false);

        }
    }

}
